package com.industrial.im.properties;

import lombok.*;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.NotBlank;


@Component
@ConfigurationProperties(prefix = "mail")
@Data
@Validated
public class EmailProperties {


    private String sendType;
    private String host;
    private int port;
    @NotBlank
    private String username;
    @NotBlank
    private String password;
    private Smtp smtp = new Smtp();

    @Data
    public static class Smtp {
        private Boolean auth;
        private SocketFactory socketFactory = new SocketFactory();
        private Boolean sslEnable;
        private Boolean tlsEnable;
        private Integer connectionTimeout;
        private Integer timeout;
        private Integer writeTimeout;


        @Data
        public static class SocketFactory {
            private String classValue;
            private Boolean fallback;
        }
    }




}



//@Component
//@EnableConfigurationProperties
//@ConfigurationProperties(prefix = "mail")
//@Data
//public class EmailProperties {
//    private String sendType;
//    private String host;
//    private int port;
//    @NotBlank
//    private String username;
//    @NotBlank
//    private String password;
//    //mail.host=smtp.163.com
//    //mail.port=465
//    //mail.username=15552431356
//    //mail.password=your-password
//    //mail.properties.mail.smtp.auth=true
//    //mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
//    //mail.properties.mail.smtp.socketFactory.fallback=false
//    //mail.properties.mail.smtp.ssl.enable=true
//    //mail.properties.mail.smtp.connectiontimeout=5000
//    //mail.properties.mail.smtp.timeout=3000
//    //mail.properties.mail.smtp.writetimeout=5000
//    private String propertiesMailSmtpAuth;
//    private String propertiesMailSmtpSocketFactoryClass;
//    private String propertiesMailSmtpSocketFactoryFallback;
//    private String propertiesMailSmtpSslEnable;
//    private String propertiesMailSmtpConnectiontimeout;
//    private String propertiesMailSmtpTimeout;
//    private String propertiesMailSmtpWritetimeout;
//    //private Properties properties = new Properties();
//
////    public String getHost() {
////        return host;
////    }
////
////    public void setHost(String host) {
////        this.host = host;
////    }
////
////    public int getPort() {
////        return port;
////    }
////
////    public void setPort(int port) {
////        this.port = port;
////    }
////
////    public String getUsername() {
////        return username;
////    }
////
////    public void setUsername(String username) {
////        this.username = username;
////    }
////
////    public String getPassword() {
////        return password;
////    }
////
////    public void setPassword(String password) {
////        this.password = password;
////    }
////
////    public Properties getProperties() {
////        return properties;
////    }
////
////    public void setProperties(Properties properties) {
////        this.properties = properties;
////    }
//
////    public static class Properties {
////        private Boolean smtpAuth;
////        private SocketFactory socketFactory = new SocketFactory();
////        private Boolean sslEnable;
////        private Integer connectionTimeout;
////        private Integer timeout;
////        private Integer writeTimeout;
////
////        public Boolean getSmtpAuth() {
////            return smtpAuth;
////        }
////
////        public void setSmtpAuth(Boolean smtpAuth) {
////            this.smtpAuth = smtpAuth;
////        }
////
////        public SocketFactory getSocketFactory() {
////            return socketFactory;
////        }
////
////        public void setSocketFactory(SocketFactory socketFactory) {
////            this.socketFactory = socketFactory;
////        }
////
////        public Boolean getSslEnable() {
////            return sslEnable;
////        }
////
////        public void setSslEnable(Boolean sslEnable) {
////            this.sslEnable = sslEnable;
////        }
////
////        public Integer getConnectionTimeout() {
////            return connectionTimeout;
////        }
////
////        public void setConnectionTimeout(Integer connectionTimeout) {
////            this.connectionTimeout = connectionTimeout;
////        }
////
////        public Integer getTimeout() {
////            return timeout;
////        }
////
////        public void setTimeout(Integer timeout) {
////            this.timeout = timeout;
////        }
////
////        public Integer getWriteTimeout() {
////            return writeTimeout;
////        }
////
////        public void setWriteTimeout(Integer writeTimeout) {
////            this.writeTimeout = writeTimeout;
////        }
////
////        public static class SocketFactory {
////            private String classValue;
////            private Boolean fallback;
////
////            public String getClassValue() {
////                return classValue;
////            }
////
////            public void setClassValue(String classValue) {
////                this.classValue = classValue;
////            }
////
////            public Boolean getFallback() {
////                return fallback;
////            }
////
////            public void setFallback(Boolean fallback) {
////                this.fallback = fallback;
////            }
////        }
////    }
//}
